import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login.vue'
import Home from '../views/home.vue'
import Welcome from '../views/welcome.vue'
import Personnel from '../views/personnel/personnel.vue'
import Configure from '../views/configure/configure.vue'
import Manage from '../views/manage/manage.vue'
import Govern from '../views/govern/govern.vue'
import Organize from '../views/organize/organize.vue'
import Upload from '../views/upload/upload.vue'
import Custom from '../views/custom/custom.vue'
import News from '../views/news/news.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/login' },
  { path: '/login', name: 'Login', component: Login },
  { path: '/home', name: 'Home', component: Home, redirect: '/welcome', 
    children: [
      {path: '/welcome', name: 'Welcome', component: Welcome},
      { path: '/personnel', name: 'personnel', component: Personnel},
      { path: '/configure', name: 'configure', component: Configure},
      { path: '/manage', name: 'manage', component: Manage},
      { path: '/govern', name: 'govern', component: Govern},
      { path: '/organize', name: 'organize', component: Organize},
      { path: '/upload', name: 'upload', component: Upload},
      { path: '/custom', name: 'custom', component: Custom},
      { path: '/news', name: 'news', component: News },

    ] 
  }
]

const router = new VueRouter({
  routes
})

// 挂载路由导航守卫
// router.beforeEach((to,from,next)=>{
//   if(to.path === '/login') return next();
//   const tokenStr = window.sessionStorage.getItem('token');
//   if (!tokenStr) return next('/login');
//   next();
// })

export default router
